<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib prefix="sys" uri="/WEB-INF/tld/sys.tld" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>自动退款记录</title>
    <jsp:include page="../import.jsp" flush="true"/>
    <style type="text/css">
        .searchArea .fieldBox .label {
            width: 70px;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }
    </style>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="fieldBox">
                    <div class="label">订单号</div>
                    <div class="field">
                        <input name="orderId" id="orderId" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">结清申请ID</div>
                    <div class="field">
                        <input name="applyIdStr" id="applyIdStr" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">支付表号</div>
                    <div class="field">
                        <input name="paySchNo" id="paySchNo" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">流程单号</div>
                    <div class="field">
                        <input name="procNo" id="procNo" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">创建时间</div>
                    <div class="field">
                        <input ligerui="width: 82" name="crtTmMin" id="crtTmMin" type="text" class="ui-datepicker" value="">
                        &nbsp;-
                        <input ligerui="width: 82" name="crtTmMax" id="crtTmMax" type="text" class="ui-datepicker" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">更新时间</div>
                    <div class="field">
                        <input ligerui="width: 82" name="mdfTmMin" id="mdfTmMin" type="text" class="ui-datepicker" value="">
                        &nbsp;-
                        <input ligerui="width: 82" name="mdfTmMax" id="mdfTmMax" type="text" class="ui-datepicker" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">退款状态</div>
                    <div class="field">
                        <input name="stsCd" id="stsCd" data-value="" placeholder="请选择" ltype="combobox">
                    </div>
                </div>

                <div class="clearFix"></div>
                <div class="formBtns notRight">
                    <span id="searchBtn" class="sq-button sq-button-round"></i>查询</span>
                    <span id="clearBtn" class="sq-button sq-button-round"></i>清空</span>
                    <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
                </div>
            </div>
        </form>
    </div>

    <div id="ligergrid1" class="sq-grid"></div>
</div>

<script type="text/javascript">
    var basePath = '<%=path%>';
    var grid = null;
    var callback = null;
    $(function () {

        grid = $("#ligergrid1").ligerGrid({
            url: basePath + '/settlement/refund/loadRefundList.do',
            parms: {},
            method: 'get',
            columns: [
                {display: '退款订单号', name: 'id', minWidth: 130, align: 'center', enabledSort: false},
                {display: '支付表号', name: 'paySchNo', width: 190, align: 'center', enabledSort: false},
                {display: '结清申请ID', name: 'applyId', width: 130, align: 'center', enabledSort: false},
                {display: '结清账号记录ID', name: 'paySchBankId', width: 130, align: 'center', enabledSort: false},
                {
                    display: '流程单号', name: 'procNo', width: 170, align: 'left', enabledSort: false,
                    render: function (rowdata, index, value) {
                        return '<a href="javascript:commShowFlow(' + index + ')">' + value + '</a>';
                    }
                },
                {display: '退款状态', name: 'stsCdNm', width: 100, align: 'center', enabledSort: false},
                {
                    display: '退款金额(元)', name: 'amount', width: 90, align: 'right', enabledSort: false,
                    render: function (rowdata, index, value) {
                        return '<font color="red">&yen;' + FormatMoney(Math.abs(value) / 100) + '</font>';
                    }
                },
                {display: '退款结果', name: 'resultStr', width: 170, align: 'center', enabledSort: false,
                    render: function (rowdata, index, value) {
                        if (StringUtils.isEmpty(value)) {
                            return value;
                        }
                        var h='<span class="gridTip" title="'+ value +'">'+ value +'</span>'
                        return h;
                    }
                },
                {display: '创建时间', name: 'crtTm', width: 140, align: 'center', enabledSort: false, render: renderDate2},
                {display: '更新时间', name: 'mdfTm', width: 140, align: 'center', enabledSort: false, render: renderDate2}
            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            checkbox: false,
            rownumbers: true,
            allowUnSelectRow: true,
            alternatingRow: true,
            frozen: false,
            detail: {
                height: 'auto',
                onShowDetail: showChildren
            }
        });
        grid.setHeight(100);


        // 退款记录状态
        $("#stsCd").ligerComboBox({
            valueField: 'key',
            textField: 'value'
        });
        liger.get("stsCd").setData(${stsCdList});

        $("#searchBar").ligerForm();
        $("#pageloading").hide();

        /* 查询 */
        $("#searchBtn").click(function (event) {
            var form = liger.get("searchBar");
            var data = form.getData();
            for (name in data) {
                grid.setParm(name, data[name]);
            }
            grid.reload();
        });

        /* 清空 */
        $("#clearBtn").click(function (event) {
            $("#resetBtn").click();  //重置 input-text
            $("#stsCd_val").val("");
        });

        callback = function () {
            grid.reload();
        };
    });

    function showChildren(row, detailPanel, callback) {
        var gridBox = document.createElement('div');
        $(gridBox).css('margin', 10);
        $(detailPanel).css({
            'padding': 10,
            'box-sizing': 'border-box'
        }).append(gridBox);
        detailGrid = $(gridBox).ligerGrid({
            url: basePath + '/settlement/refund/queryRefundDetail.do?orderId=' + row.id,
            method: 'get',
            columns: [
                { display: '签约号', name: 'signNo', width: 150, align: 'center'},
                { display: '账户名', name: 'actNm', width: 150, enabledSort:true},
                { display: '账号', name: 'actNo', width: 150, enabledSort:true},
                { display: '证件号码', name: 'identityNo', width: 150, enabledSort:true},
                { display: '预留手机号', name: 'actTel', width: 150, enabledSort:true}
            ],
            root: 'rows',
            hideLoadButton: true,
            width: '100%',
            height: 'auto',
            isScroll: false,
            rownumbers: true,
            checkbox: false,
            allowUnSelectRow: true,
            alternatingRow: false,
            onAfterShowData: callback,
            frozen: false,
            usePager: false
        });
    }

    function commShowFlow(rowindex) {
        var rowdata = grid.getRow(rowindex);
        var _pInstId = rowdata.procId;
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: {procId: _pInstId, type: "1"},
            url: basePath + '/settlement/queryFlowData.do',
            success: function (msg) {
                if (msg.success == 1) {
                    var params = "?pInsId=" + _pInstId + "&status=" + msg.data.audStsCd + "&businessKey=" + msg.data.dataId + "&formUrl=" + msg.data.formUrl;
                    Add_navTab('tab_settle_look_flow_' + _pInstId, msg.data.pno, basePath + "/flow/flow/toFlowShowPageFowBus.do" + params);
                } else {
                    top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            }
        });
    }

    //格式化时间
    function renderDate2(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
        }
        return dateStr;
    }

</script>

</body>
</html>
